package org.example.day;

import java.util.HashMap;

/**
 * @Description: TODO
 * @Author wyatt
 * @Data 2024/05/19 21:10
 */
public class Solution1535 {

    public static void main(String[] args) {
        Solution1535 solution1535 = new Solution1535();
        System.out.println(solution1535.getWinner(new int[]{1,11,22,33,44,55,66,77,88,99}, 200));
    }

    public int getWinner(int[] arr, int k) {
        int max = arr[0];
        HashMap<Integer, Integer> wineerCount = new HashMap<>();
        for(int i=1;i<arr.length;i++){
            int num = arr[i];
            if(num > max){
                max = num;
            }

            if(!wineerCount.containsKey(max)){
                wineerCount.put(max, 0);
            }

            wineerCount.put(max, wineerCount.get(max) + 1);

            if(wineerCount.get(max) >= k){
                return max;
            }

        }

        return max;
    }

}
